<?php

require(dirname(dirname(dirname(__FILE__))).'/conf/Init.php');
require PHPLIB. "/Base/Jobs/Base.php";

/**
 * 此脚本用于为微信服务号创建一个菜单，具体菜单格式应在/conf/wechat/menu.php中配置
 */
class Menu extends \Base\Jobs\Base {
    public function exec($argv=null) {
        $buttons = \S\Config::get("menu", "wechat");

        $menuService = new \Modules\Wechat\Lib\Menu();
        $result = $menuService->createMenu(array("button" => $buttons));
        if ($result) {
            echo date("Y-m-d H:i:s") . " create menu success." . PHP_EOL . PHP_EOL;
            var_dump($menuService->getMenu());

            return ;
        }

        echo date("Y-m-d H:i:s") . " create menu fail." . PHP_EOL;
    }
}
new Menu($argv);